﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using EzDesk.DesktopClient.Event;
using EzDesk.DesktopClient.MVVMEnhance;
using EzDesk.DesktopClient.ViewContract;
using EzDesk.DesktopClient.ServiceLocator.ClientService;

namespace EzDesk.DesktopClient.ViewModel
{
    public  class TaskItemViewModel:ViewModelWithSingleContainer<ITaskItemView>
    {

        private AppTask _taskModel;

        public AppTask TaskModel
        {
            get { return _taskModel; }
            set { _taskModel = value;
            RaisePropertyChanged("TaskModel");
            }
        }


        public TaskItemViewModel()
            : base()
        {
            Init();
        }

        public TaskItemViewModel(AppTask task):base()
        {
            this.TaskModel = task;
            Init();
        }

        private void Init()
        {
            this.View.OpenTask += new EventHandler(View_OpenTask);
        }

        void View_OpenTask(object sender, EventArgs e)
        {
            FunctionNavigateEvent.Instance.Publish(new FunctionNavigateArgs { Url = this.TaskModel.FuncUrl });
        }
    }
}
